// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'

import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';

import VueRouter from 'vue-router'

import Dept from "./components/Dept"
import Company from "./components/Company"
import User from "./components/User"
import HelloWorld from "./components/HelloWorld"
import DeptList from "./components/DeptList"
import DeptInfo from "./components/DeptInfo"

Vue.use(VueRouter)

Vue.use(ElementUI);

Vue.config.productionTip = false

//路由映射规则，路径 --- 组件的映射关系
var routes = [{
		path: "/dept/list/:id/:name", 
		component: Dept,
		children: [
			{
				path: "/deptlist",
				component: DeptList
			},
			{
				path: "/deptinfo",
				component: DeptInfo
			},{
				path:"/u",
				redirect:"/user/list"
			}
		]
	},

	{
		path: "/company/list/:age",
		props:true,
		component: Company
	},
	{
		path: "/user/list/:name/:hobby",
		component: User,
		name:"userlist"
	},
	{
		path: "/helloworld",
		components: {
			right: HelloWorld,
			default: Company
		},
		name: "hello"
	}
]

//创建路由对象
var router = new VueRouter({
	routes,
	"mode": "history"
})

router.beforeEach((to, from, next) => {
  	console.log(to);
  	console.log(from);
  	next();
})

/* eslint-disable no-new */
new Vue({
	el: '#app',
	components: {
		App
	},
	template: '<App/>',
	router
})